/*
 * Mutex.cpp
 *
 *  PEREIRA, FERNANDO ROQUE
 *  91610
 */

#include "Mutex.h"

Mutex::Mutex() {
	pthread_mutex_init(&this->mutex, NULL);
	pthread_cond_init(&this->conditionVariable, 0);
}

Mutex::~Mutex() {
	pthread_cond_destroy(&this->conditionVariable);
	pthread_mutex_destroy(&this->mutex);
}

void Mutex::lockMutex() {
	pthread_mutex_lock(&this->mutex);
}

void Mutex::unlockMutex() {
	pthread_mutex_unlock(&this->mutex);
}

void Mutex::wait() {
	pthread_cond_wait(&this->conditionVariable, &this->mutex);
}

void Mutex::signal() {
	pthread_cond_signal(&this->conditionVariable);
}
